public class Demo6 {
    public static void main(String[] args) {
    int i;
    int s;
    int ret;
    int count = 3;
    int count2 = 0;
    for(i = 0;i<=1000;i++)
    {
        s = i;
        ret = 0;
        while(s!=0)
        {
            ret+= (int) Math.pow(s%10,count);
            s/=10;
        }
        if(ret==i)
        {
            System.out.print(i+"  ");
            count2++;
        }
        if(count2%6==0)
            System.out.print("\n");
    }
    }
}
